/*
 * @(#)MonitoringBOImpl.java $version 2012-8-10
 * 
 * Copyright 2012 NADOSTAR Gruop. All rights Reserved.
 * NADOSTAR PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nadostar.iims.monitoring.bo.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nadostar.extensions.util.DataMap;
import com.nadostar.iims.model.MonitoringParamModel;
import com.nadostar.iims.monitoring.bo.MonitoringBO;
import com.nadostar.iims.monitoring.dao.AtcDAO;
import com.nadostar.iims.monitoring.dao.CmtDAO;
import com.nadostar.iims.util.CommonConst;

/**
 * The Class MonitoringBOImpl.
 * 
 * @author Lixing
 *
 */
@Service("MonitoringBO")
@Transactional(readOnly = true)
public class MonitoringBOImpl implements MonitoringBO {
	private static Log log = LogFactory.getLog(MonitoringBOImpl.class);
	
	@Autowired
	private AtcDAO atcDAO = null;
	
	@Autowired
	private CmtDAO cmtDAO = null;
	

	public List<DataMap> getMonitoringList(MonitoringParamModel model, int offset, int count) {
		List<DataMap> result = new ArrayList<DataMap>();
		try {
			if(CommonConst.TARGET_OF_ATC.equals(model.getTargetCd())) {
				result = atcDAO.selectMonitoringList(model, offset, count);
			} else if(CommonConst.TARGET_OF_CMT.equals(model.getTargetCd())) {
				result = cmtDAO.selectMonitoringList(model, offset, count);
			}
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<DataMap>();
		}
		return result;
	}

	public int getMonitoringListCount(MonitoringParamModel model) {
		int result = 0;
		try {
			if(CommonConst.TARGET_OF_ATC.equals(model.getTargetCd())) {
				result = atcDAO.selectMonitoringListCount(model);
			} else if(CommonConst.TARGET_OF_CMT.equals(model.getTargetCd())) {
				result = cmtDAO.selectMonitoringListCount(model);
			}
		} catch (Exception e) {
			log.error(e, e);
			return 0;
		}
		
		return result;
	}

	public List<DataMap> getMonitoringStatistics(MonitoringParamModel model) {
		List<DataMap> result = new ArrayList<DataMap>();
		try {
			result = atcDAO.selectMonitoringStatistics(model);
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<DataMap>();
		}
		return result;
	}

	public List<DataMap> getDeletedMonitoringList(MonitoringParamModel model, int offset, int count) {
		List<DataMap> result = new ArrayList<DataMap>();
		try {
			result = atcDAO.selectDeletedMonitoringList(model, offset, count);
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<DataMap>();
		}
		return result;
	}

	public int getDeletedMonitoringListCount(MonitoringParamModel model) {
		try {
			return atcDAO.selectDeletedMonitoringListCount(model);
		} catch (Exception e) {
			log.error(e, e);
			return 0;
		}
	}



}
